home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / comm / thor / BounceSpam.lha / BounceSpam.thor < prev   
Text File  |  1997-03-18  |  5KB  |  172 lines

  1. /* Add Spammer's Email address to the GetMail configuration file
  2.  
  3.    $VER: BounceSpam.thor V1.3 (18.3.97) © 1997 Roy E Brown
  4.  
  5.    GetMail is © 1996-97 Philip Stokes
  6.  
  7.    This script will add the current message 'from address' to either the
  8.    'Kill Addresses' or the 'Allowed Addresses' section of GetMail's
  9.    configuration file.
  10.  
  11.    The 'Kill' option is useful for automatically adding spammers to your kill
  12.    list, as any mail from these addresses is automatically bounced back to the
  13.    sender without being downloaded to your system.
  14.  
  15.    The 'Allowed' option allows GetMail to receive EMail from the specified
  16.    addresses without asking the user for confirmation first. This option is
  17.    configurable within GetMail - you should read the GetMail documentation
  18.    carefully. You should manually delete the word 'any' from this section if
  19.    you add new addresses.
  20.  
  21.    The script assumes that you have the following 3 lines at the end of your
  22.    existing 'Kill Addresses';
  23.  
  24.    <Blank Line>
  25.    #  ===============================================================
  26.    #  Allowed Addresses
  27.  
  28.    ... and these 2 lines at the end of the file:
  29.  
  30.    <Blank Line>
  31.    # EOF
  32.  
  33.    If you haven't touched these lines at all, then the script should work OK.
  34.  
  35.    This script will only work from within the EMail conference of Thor.
  36.  
  37.    Please change the 2 variables below to reflect the name of your EMail
  38.    conference and the full path location of SMTP.conf */
  39.  
  40. UULibPath="Work:Internet_System/usr/lib/SMTP.conf"    /* Full path to SMTP.conf */
  41.  
  42. /* Please do not alter anything below this line. Thank you */
  43.  
  44. Vers="BounceSpam.thor V1.3 © 1997 Roy E Brown"
  45. lf='0a'x
  46. lines=0
  47. txt=''
  48.  
  49. Signal ON Syntax
  50.  
  51. Options Results
  52.  
  53. Options FailAt 21
  54.  
  55. /* Is Thor active? */
  56. If ~Show('P','THOR.01') Then
  57.   Do
  58.     Say "Thor needs to be available for this script"
  59.     Exit
  60.   End
  61.  
  62. /* Check for Getmail's config file in UULib: */
  63. If ~Exists(UULibPath) Then
  64.   Do
  65.     Address THOR.01
  66.     REQUESTNOTIFY TEXT '"'vers'\n\n   Are you sure that you use GetMail?\n  I cannot find the configuration file.\n\n            UULIB:SMTP.conf" BT "_Exit"'
  67.     Exit
  68.   End
  69.  
  70. /* Check for BBSRead port. Open if necessary */
  71. If ~Show('P','BBSREAD') Then
  72.   Do
  73.     Address Command
  74.     "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  75.     "WaitForPort BBSREAD"
  76.   End
  77.  
  78. /* Let's get the file open and find out how many lines etc */
  79. If Open(config,UULibPath,r)~=1 Then
  80.   Do
  81.     REQUESTNOTIFY TEXT '"'vers'\n\nUnable to open the Getmail configuration file" BT "_Exit"'
  82.     Exit
  83.   End
  84. Else
  85.   Do Until EOF(config)
  86.     Do
  87.       String=Readln(config)
  88.       lines=lines+1
  89.       txt=txt||string||lf
  90.     End
  91.   txt.lines=string
  92.   End
  93.  
  94. Call Close(config)
  95.  
  96. /* Get details of current system and message */
  97. Address THOR.01
  98. CURRENTSYSTEM stem CURRENT
  99. CURRENTMSG stem MSG
  100.  
  101. Address BBSREAD
  102. READBRMESSAGE CURRENT.BBSNAME CURRENT.CONFNAME MSG.MSGNR HEADSTEM Header
  103. IF RC ~=0 Then Call BBSError
  104. Addr=HEADER.FROMADDR
  105.  
  106. /* What do we want to do - Kill or Accept an address */
  107. Address THOR.01
  108. REQUESTNOTIFY TEXT '"'vers'\n\n   Do you wish to add this address to\n   the ''Kill'' or the ''Accept'' section?\n\n'addr'\n" BT "_Kill|_Accept|_Cancel"'
  109. If Result=0 Then Exit
  110. If Result=1 Then
  111.   Do
  112.     Dest="'Kill'"
  113.     Call Kill
  114.   End
  115. If Result=2 Then
  116.   Do
  117.     Dest="'Accept'"
  118.     Call Accept
  119.   End
  120.  
  121. /* let's write the new configuration file */
  122. Call Open(newfile,'UULib:SMTP.conf',w)
  123. Call Writeln(newfile,txt2)
  124.  
  125. /* Let's tell the user what we have done */
  126. Address THOR.01
  127. REQUESTNOTIFY TEXT '"'vers'\n\n The following EMail address has been\n added to the 'dest' section of the\n      GetMail configuration file.\n\n'addr'\n" BT "_Thank You"'
  128.  
  129. Exit
  130.  
  131. /* Let's find the end of the 'Kill Addresses' section and insert the new address */
  132. Kill:
  133. Call Check
  134. Do x=1 To lines
  135.   If txt.x="#  Allowed Addresses" Then
  136.     Do
  137.       x=x-1
  138.       Leave
  139.     End
  140. End
  141.   bar=Length(txt.x)+3
  142.   pos=Index(txt,"#  Allowed Addresses")
  143.   insertpos=pos-bar
  144.   txt2=Insert(addr||lf,txt,insertpos)
  145. Return
  146.  
  147. /* Let's find the end of the 'Allowed Addresses' section and insert the new address */
  148. Accept:
  149.   Call Check
  150.   insertpos=Index(txt,"# EOF")-2
  151.   txt2=Insert(addr||lf,txt,insertpos)
  152. Return
  153.  
  154. /* Let's make sure that the user really wants to do this */
  155. Check:
  156.   Address THOR.01
  157.   REQUESTNOTIFY TEXT '"'vers'\n\n     Are you sure that you wish to\n    add the following EMail address\n     to the 'dest' section of the\n      GetMail configuration file?\n\n'addr'\n" BT "_Positive!|Perhaps Not"'
  158.   If Result=0 Then Exit
  159. Return
  160.  
  161. Syntax:
  162.   Address THOR.01
  163.   REQUESTNOTIFY TEXT '"'vers'\n\nA syntax error ('RC') occurred.\n'ErrorText(RC)'\nin line 'SIGL'" BT "_Exit"'
  164.   Exit
  165. Return
  166.  
  167. BBSError:
  168.   Address THOR.01
  169.   REQUESTNOTIFY TEXT '"'vers'\n\nBBSREAD ERROR\n'BBSREAD.LASTERROR'" BT "_Exit"'
  170.   Exit
  171. Return
  172.